package com.mobileares.midp.widgets.client.page;

import com.google.gwt.user.client.ui.Widget;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Tom
 * Date: 2010-10-29
 * Time: 11:18:38
 * To change this template use File | Settings | File Templates.
 */
public class WidgetFunction implements IFunctionModel, HasAccess {
    private Widget widget;
    private String code;
    private String text;
    private List<AbstractAccess> accesses;

    public WidgetFunction(Widget w, String text) {
        this(w, text, text);
    }

    public WidgetFunction(Widget widget, String code, String text) {
        this.widget = widget;
        this.code = code;
        this.text = text;
    }

    public Widget getWidget() {
        return widget;
    }

    public void setWidget(Widget widget) {
        this.widget = widget;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public void addAccess(AbstractAccess access) {
        if (accesses == null)
            accesses = new ArrayList();
        accesses.add(access);
    }

    public void removeAccess(AbstractAccess access) {
        if (accesses != null)
            accesses.remove(access);
    }

    public List<AbstractAccess> getAccesses() {
        return accesses;  
    }
}
